package com.andy.customerService.vo;


import com.andy.customerService.enums.ExceptionEnum;
import com.andy.customerService.enums.StatusEnum;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class JsonBaseResult<T> implements Serializable {

    private T result;
    private Integer errorCode;
    private String errorMessage;
    private StatusEnum resultStatus = StatusEnum.SUCCEED;

    public void setErrorCode(ExceptionEnum exceptionEnum) {
        this.errorCode = exceptionEnum.getCode();
        this.errorMessage = exceptionEnum.getMessage();
        this.resultStatus = StatusEnum.FAILED;
    }

    public T getResult() {
        return result;
    }


}

